| | | 1 | | // Copyright (c) 2020-2023 dotBunny Inc. |
| | | 2 | | // dotBunny licenses this file to you under the BSL-1.0 license. |
| | | 3 | | // See the LICENSE file in the project root for more information. |
| | | 4 | | |
| | | 5 | | using System; |
| | | 6 | | using GDX.Collections; |
| | | 7 | | using UnityEngine; |
| | | 8 | | |
| | | 9 | | namespace GDX.Tables |
| | | 10 | | { |
| | | 11 | | |
| | | 12 | | [CreateAssetMenu(menuName = "GDX/Stable Table", fileName = "GDXStableTable")] |
| | | 13 | | [Serializable] |
| | | 14 | | public class StableTable : ScriptableObject, ITable |
| | | 15 | | { |
| | | 16 | | [Serializable] |
| | | 17 | | internal struct ColumnEntry |
| | | 18 | | { |
| | | 19 | | public Serializable.SerializableTypes ColumnType; |
| | | 20 | | public int columnDenseIndex; |
| | | 21 | | } |
| | | 22 | | |
| | | 23 | | [SerializeField] internal ArrayHolder<string>[] allStringColumns; |
| | | 24 | | [SerializeField] internal ArrayHolder<bool>[] allBoolColumns; |
| | | 25 | | [SerializeField] internal ArrayHolder<char>[] allCharColumns; |
| | | 26 | | [SerializeField] internal ArrayHolder<sbyte>[] allSbyteColumns; |
| | | 27 | | [SerializeField] internal ArrayHolder<byte>[] allByteColumns; |
| | | 28 | | [SerializeField] internal ArrayHolder<short>[] allShortColumns; |
| | | 29 | | [SerializeField] internal ArrayHolder<ushort>[] allUshortColumns; |
| | | 30 | | [SerializeField] internal ArrayHolder<int>[] allIntColumns; |
| | | 31 | | [SerializeField] internal ArrayHolder<uint>[] allUintColumns; |
| | | 32 | | [SerializeField] internal ArrayHolder<long>[] allLongColumns; |
| | | 33 | | [SerializeField] internal ArrayHolder<ulong>[] allUlongColumns; |
| | | 34 | | [SerializeField] internal ArrayHolder<float>[] allFloatColumns; |
| | | 35 | | [SerializeField] internal ArrayHolder<double>[] allDoubleColumns; |
| | | 36 | | [SerializeField] internal ArrayHolder<Vector2>[] allVector2Columns; |
| | | 37 | | [SerializeField] internal ArrayHolder<Vector3>[] allVector3Columns; |
| | | 38 | | [SerializeField] internal ArrayHolder<Vector4>[] allVector4Columns; |
| | | 39 | | [SerializeField] internal ArrayHolder<Vector2Int>[] allVector2IntColumns; |
| | | 40 | | [SerializeField] internal ArrayHolder<Vector3Int>[] allVector3IntColumns; |
| | | 41 | | [SerializeField] internal ArrayHolder<Quaternion>[] allQuaternionColumns; |
| | | 42 | | [SerializeField] internal ArrayHolder<Rect>[] allRectColumns; |
| | | 43 | | [SerializeField] internal ArrayHolder<RectInt>[] allRectIntColumns; |
| | | 44 | | [SerializeField] internal ArrayHolder<Color>[] allColorColumns; |
| | | 45 | | [SerializeField] internal ArrayHolder<LayerMask>[] allLayerMaskColumns; |
| | | 46 | | [SerializeField] internal ArrayHolder<Bounds>[] allBoundsColumns; |
| | | 47 | | [SerializeField] internal ArrayHolder<BoundsInt>[] allBoundsIntColumns; |
| | | 48 | | [SerializeField] internal ArrayHolder<Hash128>[] allHash128Columns; |
| | | 49 | | [SerializeField] internal ArrayHolder<Gradient>[] allGradientColumns; |
| | | 50 | | [SerializeField] internal ArrayHolder<AnimationCurve>[] allAnimationCurveColumns; |
| | | 51 | | [SerializeField] internal ArrayHolder<UnityEngine.Object>[] allObjectRefColumns; |
| | 0 | 52 | | [SerializeField] internal ArrayHolder<string>[] allColumnNames = new ArrayHolder<string>[Serializable.Serializab |
| | 0 | 53 | | [SerializeField] internal ArrayHolder<int>[] allColumnOrders = new ArrayHolder<int>[Serializable.SerializableTyp |
| | | 54 | | |
| | | 55 | | |
| | | 56 | | [SerializeField] internal string[] allRowNames; |
| | | 57 | | [SerializeField] internal int[] rowIDToDenseIndexMap; |
| | | 58 | | [SerializeField] internal int[] rowDenseIndexToIDMap; |
| | | 59 | | [SerializeField] internal int rowEntriesFreeListHead; |
| | | 60 | | |
| | | 61 | | |
| | | 62 | | [SerializeField] |
| | | 63 | | internal int rowCount; |
| | | 64 | | |
| | | 65 | | [SerializeField] |
| | | 66 | | internal ColumnEntry[] columnIDToDenseIndexMap; |
| | | 67 | | |
| | | 68 | | // TODO move with other block |
| | 0 | 69 | | [SerializeField] ArrayHolder<int>[] columnDenseIndexToIDMap = new ArrayHolder<int>[Serializable.SerializableType |
| | | 70 | | |
| | | 71 | | [SerializeField] |
| | | 72 | | internal int columnEntriesFreeListHead; |
| | | 73 | | |
| | | 74 | | [SerializeField] |
| | | 75 | | internal int combinedColumnCount; |
| | | 76 | | |
| | | 77 | | [SerializeField] |
| | 0 | 78 | | internal ulong dataVersion = 1; |
| | | 79 | | |
| | | 80 | | |
| | | 81 | | public ulong GetDataVersion() |
| | 0 | 82 | | { |
| | 0 | 83 | | return dataVersion; |
| | 0 | 84 | | } |
| | | 85 | | |
| | | 86 | | /// <inheritdoc /> |
| | | 87 | | public int GetColumnCount() |
| | 0 | 88 | | { |
| | 0 | 89 | | return combinedColumnCount; |
| | 0 | 90 | | } |
| | | 91 | | |
| | | 92 | | /// <inheritdoc /> |
| | | 93 | | public int GetRowCount() |
| | 0 | 94 | | { |
| | 0 | 95 | | return rowCount; |
| | 0 | 96 | | } |
| | | 97 | | |
| | | 98 | | public ITable.ColumnDescription[] GetOrderedColumns() |
| | 0 | 99 | | { |
| | 0 | 100 | | if (combinedColumnCount == 0) return null; |
| | 0 | 101 | | ITable.ColumnDescription[] returnArray = new ITable.ColumnDescription[combinedColumnCount]; |
| | | 102 | | |
| | 0 | 103 | | for (int columnIndex = 0; columnIndex < Serializable.SerializableTypesCount; columnIndex++) |
| | 0 | 104 | | { |
| | | 105 | | |
| | 0 | 106 | | int[] columnOrders = allColumnOrders[columnIndex].TArray; |
| | 0 | 107 | | int columnOrdersLength = columnOrders?.Length ?? 0; |
| | | 108 | | |
| | 0 | 109 | | int[] columnIndices = columnDenseIndexToIDMap[columnIndex].TArray; |
| | 0 | 110 | | string[] columnNames = allColumnNames[columnIndex].TArray; |
| | | 111 | | |
| | 0 | 112 | | for (int i = 0; i < columnOrdersLength; i++) |
| | 0 | 113 | | { |
| | 0 | 114 | | returnArray[columnOrders[i]] = new ITable.ColumnDescription |
| | | 115 | | { |
| | | 116 | | Name = columnNames[i], |
| | | 117 | | Index = columnIndices[i], |
| | | 118 | | Type = (Serializable.SerializableTypes)columnIndex |
| | | 119 | | }; |
| | 0 | 120 | | } |
| | 0 | 121 | | } |
| | 0 | 122 | | return returnArray; |
| | 0 | 123 | | } |
| | | 124 | | |
| | | 125 | | |
| | | 126 | | // END - View Hacks |
| | | 127 | | |
| | | 128 | | // TODO: Way to set column name |
| | | 129 | | |
| | | 130 | | |
| | | 131 | | |
| | | 132 | | public void AddRow(string rowName = null, int insertAt = -1) |
| | 0 | 133 | | { |
| | | 134 | | // TODO: For adam to do |
| | | 135 | | // int rowIndex = rowEntriesFreeListHead; |
| | | 136 | | // int rowIDToDenseIndexMapLength = rowIDToDenseIndexMap?.Length ?? 0; |
| | | 137 | | // if (rowIndex >= rowIDToDenseIndexMapLength) |
| | | 138 | | // { |
| | | 139 | | // int newSize = rowIndex * 2; |
| | | 140 | | // newSize = newSize == 0 ? 1 : newSize; |
| | | 141 | | // Array.Resize(ref rowIDToDenseIndexMap, newSize); |
| | | 142 | | // for (int i = 0; i < rowIndex; i++) |
| | | 143 | | // { |
| | | 144 | | // rowIDToDenseIndexMap[rowIndex + i] = rowIndex + i + 1; |
| | | 145 | | // } |
| | | 146 | | // } |
| | | 147 | | // int denseIndexToIDMapLength = rowDenseIndexToIDMap?.Length ?? 0; |
| | | 148 | | // Array.Resize(ref rowDenseIndexToIDMap, denseIndexToIDMapLength + 1); |
| | | 149 | | // |
| | | 150 | | // |
| | | 151 | | // rowDenseIndexToIDMap[denseIndexToIDMapLength] = rowIndex; |
| | | 152 | | |
| | | 153 | | |
| | 0 | 154 | | insertAt = insertAt < 0 ? rowCount : insertAt; |
| | | 155 | | |
| | 0 | 156 | | Array.Resize(ref allRowNames, rowCount + 1); |
| | 0 | 157 | | for (int i = rowCount; i > insertAt; i--) |
| | 0 | 158 | | { |
| | 0 | 159 | | allRowNames[i] = allRowNames[i - 1]; |
| | 0 | 160 | | } |
| | | 161 | | |
| | 0 | 162 | | rowName ??= string.Empty; |
| | 0 | 163 | | allRowNames[insertAt] = rowName; |
| | | 164 | | |
| | 0 | 165 | | InsertRowsOfTypeInternal(ref allStringColumns, insertAt, 1); |
| | 0 | 166 | | InsertRowsOfTypeInternal(ref allBoolColumns, insertAt, 1); |
| | 0 | 167 | | InsertRowsOfTypeInternal(ref allCharColumns, insertAt, 1); |
| | 0 | 168 | | InsertRowsOfTypeInternal(ref allSbyteColumns, insertAt, 1); |
| | 0 | 169 | | InsertRowsOfTypeInternal(ref allByteColumns, insertAt, 1); |
| | 0 | 170 | | InsertRowsOfTypeInternal(ref allShortColumns, insertAt, 1); |
| | 0 | 171 | | InsertRowsOfTypeInternal(ref allUshortColumns, insertAt, 1); |
| | 0 | 172 | | InsertRowsOfTypeInternal(ref allIntColumns, insertAt, 1); |
| | 0 | 173 | | InsertRowsOfTypeInternal(ref allUintColumns, insertAt, 1); |
| | 0 | 174 | | InsertRowsOfTypeInternal(ref allLongColumns, insertAt, 1); |
| | 0 | 175 | | InsertRowsOfTypeInternal(ref allUlongColumns, insertAt, 1); |
| | 0 | 176 | | InsertRowsOfTypeInternal(ref allFloatColumns, insertAt, 1); |
| | 0 | 177 | | InsertRowsOfTypeInternal(ref allDoubleColumns, insertAt, 1); |
| | 0 | 178 | | InsertRowsOfTypeInternal(ref allVector2Columns, insertAt, 1); |
| | 0 | 179 | | InsertRowsOfTypeInternal(ref allVector3Columns, insertAt, 1); |
| | 0 | 180 | | InsertRowsOfTypeInternal(ref allVector4Columns, insertAt, 1); |
| | 0 | 181 | | InsertRowsOfTypeInternal(ref allVector2IntColumns, insertAt, 1); |
| | 0 | 182 | | InsertRowsOfTypeInternal(ref allVector3IntColumns, insertAt, 1); |
| | 0 | 183 | | InsertRowsOfTypeInternal(ref allQuaternionColumns, insertAt, 1); |
| | 0 | 184 | | InsertRowsOfTypeInternal(ref allRectColumns, insertAt, 1); |
| | 0 | 185 | | InsertRowsOfTypeInternal(ref allRectIntColumns, insertAt, 1); |
| | 0 | 186 | | InsertRowsOfTypeInternal(ref allColorColumns, insertAt, 1); |
| | 0 | 187 | | InsertRowsOfTypeInternal(ref allLayerMaskColumns, insertAt, 1); |
| | 0 | 188 | | InsertRowsOfTypeInternal(ref allBoundsColumns, insertAt, 1); |
| | 0 | 189 | | InsertRowsOfTypeInternal(ref allBoundsIntColumns, insertAt, 1); |
| | 0 | 190 | | InsertRowsOfTypeInternal(ref allHash128Columns, insertAt, 1); |
| | 0 | 191 | | InsertRowsOfTypeInternal(ref allGradientColumns, insertAt, 1); |
| | 0 | 192 | | InsertRowsOfTypeInternal(ref allAnimationCurveColumns, insertAt, 1); |
| | 0 | 193 | | InsertRowsOfTypeInternal(ref allObjectRefColumns, insertAt, 1); |
| | | 194 | | |
| | 0 | 195 | | ++rowCount; |
| | 0 | 196 | | dataVersion++; |
| | 0 | 197 | | } |
| | | 198 | | |
| | | 199 | | public void AddRows(int numberOfNewRows, string[] rowNames = null, int insertAt = -1) |
| | 0 | 200 | | { |
| | 0 | 201 | | insertAt = insertAt < 0 ? rowCount : insertAt; |
| | | 202 | | |
| | 0 | 203 | | Array.Resize(ref allRowNames, rowCount + 1); |
| | 0 | 204 | | for (int i = rowCount; i > insertAt; i--) |
| | 0 | 205 | | { |
| | 0 | 206 | | allRowNames[i] = allRowNames[i - 1]; |
| | 0 | 207 | | } |
| | | 208 | | |
| | 0 | 209 | | string empty = string.Empty; |
| | 0 | 210 | | int rowNamesLength = rowNames?.Length ?? 0; |
| | 0 | 211 | | for (int i = 0; i < rowNames.Length; i++) |
| | 0 | 212 | | { |
| | 0 | 213 | | string nameAt = rowNames[i]; |
| | 0 | 214 | | allRowNames[insertAt + i] = nameAt ?? empty; |
| | 0 | 215 | | } |
| | | 216 | | |
| | 0 | 217 | | for (int i = rowNamesLength; i < numberOfNewRows; i++) |
| | 0 | 218 | | { |
| | 0 | 219 | | allRowNames[insertAt + i] = empty; |
| | 0 | 220 | | } |
| | | 221 | | |
| | 0 | 222 | | InsertRowsOfTypeInternal(ref allStringColumns, insertAt, numberOfNewRows); |
| | 0 | 223 | | InsertRowsOfTypeInternal(ref allBoolColumns, insertAt, numberOfNewRows); |
| | 0 | 224 | | InsertRowsOfTypeInternal(ref allCharColumns, insertAt, numberOfNewRows); |
| | 0 | 225 | | InsertRowsOfTypeInternal(ref allSbyteColumns, insertAt, numberOfNewRows); |
| | 0 | 226 | | InsertRowsOfTypeInternal(ref allByteColumns, insertAt, numberOfNewRows); |
| | 0 | 227 | | InsertRowsOfTypeInternal(ref allShortColumns, insertAt, numberOfNewRows); |
| | 0 | 228 | | InsertRowsOfTypeInternal(ref allUshortColumns, insertAt, numberOfNewRows); |
| | 0 | 229 | | InsertRowsOfTypeInternal(ref allIntColumns, insertAt, numberOfNewRows); |
| | 0 | 230 | | InsertRowsOfTypeInternal(ref allUintColumns, insertAt, numberOfNewRows); |
| | 0 | 231 | | InsertRowsOfTypeInternal(ref allLongColumns, insertAt, numberOfNewRows); |
| | 0 | 232 | | InsertRowsOfTypeInternal(ref allUlongColumns, insertAt, numberOfNewRows); |
| | 0 | 233 | | InsertRowsOfTypeInternal(ref allFloatColumns, insertAt, numberOfNewRows); |
| | 0 | 234 | | InsertRowsOfTypeInternal(ref allDoubleColumns, insertAt, numberOfNewRows); |
| | 0 | 235 | | InsertRowsOfTypeInternal(ref allVector2Columns, insertAt, numberOfNewRows); |
| | 0 | 236 | | InsertRowsOfTypeInternal(ref allVector3Columns, insertAt, numberOfNewRows); |
| | 0 | 237 | | InsertRowsOfTypeInternal(ref allVector4Columns, insertAt, numberOfNewRows); |
| | 0 | 238 | | InsertRowsOfTypeInternal(ref allVector2IntColumns, insertAt, numberOfNewRows); |
| | 0 | 239 | | InsertRowsOfTypeInternal(ref allVector3IntColumns, insertAt, numberOfNewRows); |
| | 0 | 240 | | InsertRowsOfTypeInternal(ref allQuaternionColumns, insertAt, numberOfNewRows); |
| | 0 | 241 | | InsertRowsOfTypeInternal(ref allRectColumns, insertAt, numberOfNewRows); |
| | 0 | 242 | | InsertRowsOfTypeInternal(ref allRectIntColumns, insertAt, numberOfNewRows); |
| | 0 | 243 | | InsertRowsOfTypeInternal(ref allColorColumns, insertAt, numberOfNewRows); |
| | 0 | 244 | | InsertRowsOfTypeInternal(ref allLayerMaskColumns, insertAt, numberOfNewRows); |
| | 0 | 245 | | InsertRowsOfTypeInternal(ref allBoundsColumns, insertAt, numberOfNewRows); |
| | 0 | 246 | | InsertRowsOfTypeInternal(ref allBoundsIntColumns, insertAt, numberOfNewRows); |
| | 0 | 247 | | InsertRowsOfTypeInternal(ref allHash128Columns, insertAt, numberOfNewRows); |
| | 0 | 248 | | InsertRowsOfTypeInternal(ref allGradientColumns, insertAt, numberOfNewRows); |
| | 0 | 249 | | InsertRowsOfTypeInternal(ref allAnimationCurveColumns, insertAt, numberOfNewRows); |
| | 0 | 250 | | InsertRowsOfTypeInternal(ref allObjectRefColumns, insertAt, numberOfNewRows); |
| | | 251 | | |
| | 0 | 252 | | rowCount += numberOfNewRows; |
| | 0 | 253 | | dataVersion++; |
| | 0 | 254 | | } |
| | | 255 | | |
| | | 256 | | public void RemoveRow(int removeAt) |
| | 0 | 257 | | { |
| | 0 | 258 | | int newRowCount = rowCount - 1; |
| | 0 | 259 | | for (int j = removeAt; j < newRowCount; j++) |
| | 0 | 260 | | { |
| | 0 | 261 | | allRowNames[j] = allRowNames[j + 1]; |
| | 0 | 262 | | } |
| | | 263 | | |
| | 0 | 264 | | Array.Resize(ref allRowNames, newRowCount); |
| | | 265 | | |
| | 0 | 266 | | DeleteRowsOfTypeInternal(ref allStringColumns, removeAt, 1); |
| | 0 | 267 | | DeleteRowsOfTypeInternal(ref allBoolColumns, removeAt, 1); |
| | 0 | 268 | | DeleteRowsOfTypeInternal(ref allCharColumns, removeAt, 1); |
| | 0 | 269 | | DeleteRowsOfTypeInternal(ref allSbyteColumns, removeAt, 1); |
| | 0 | 270 | | DeleteRowsOfTypeInternal(ref allByteColumns, removeAt, 1); |
| | 0 | 271 | | DeleteRowsOfTypeInternal(ref allShortColumns, removeAt, 1); |
| | 0 | 272 | | DeleteRowsOfTypeInternal(ref allUshortColumns, removeAt, 1); |
| | 0 | 273 | | DeleteRowsOfTypeInternal(ref allIntColumns, removeAt, 1); |
| | 0 | 274 | | DeleteRowsOfTypeInternal(ref allUintColumns, removeAt, 1); |
| | 0 | 275 | | DeleteRowsOfTypeInternal(ref allLongColumns, removeAt, 1); |
| | 0 | 276 | | DeleteRowsOfTypeInternal(ref allUlongColumns, removeAt, 1); |
| | 0 | 277 | | DeleteRowsOfTypeInternal(ref allFloatColumns, removeAt, 1); |
| | 0 | 278 | | DeleteRowsOfTypeInternal(ref allDoubleColumns, removeAt, 1); |
| | 0 | 279 | | DeleteRowsOfTypeInternal(ref allVector2Columns, removeAt, 1); |
| | 0 | 280 | | DeleteRowsOfTypeInternal(ref allVector3Columns, removeAt, 1); |
| | 0 | 281 | | DeleteRowsOfTypeInternal(ref allVector4Columns, removeAt, 1); |
| | 0 | 282 | | DeleteRowsOfTypeInternal(ref allVector2IntColumns, removeAt, 1); |
| | 0 | 283 | | DeleteRowsOfTypeInternal(ref allVector3IntColumns, removeAt, 1); |
| | 0 | 284 | | DeleteRowsOfTypeInternal(ref allQuaternionColumns, removeAt, 1); |
| | 0 | 285 | | DeleteRowsOfTypeInternal(ref allRectColumns, removeAt, 1); |
| | 0 | 286 | | DeleteRowsOfTypeInternal(ref allRectIntColumns, removeAt, 1); |
| | 0 | 287 | | DeleteRowsOfTypeInternal(ref allColorColumns, removeAt, 1); |
| | 0 | 288 | | DeleteRowsOfTypeInternal(ref allLayerMaskColumns, removeAt, 1); |
| | 0 | 289 | | DeleteRowsOfTypeInternal(ref allBoundsColumns, removeAt, 1); |
| | 0 | 290 | | DeleteRowsOfTypeInternal(ref allBoundsIntColumns, removeAt, 1); |
| | 0 | 291 | | DeleteRowsOfTypeInternal(ref allHash128Columns, removeAt, 1); |
| | 0 | 292 | | DeleteRowsOfTypeInternal(ref allGradientColumns, removeAt, 1); |
| | 0 | 293 | | DeleteRowsOfTypeInternal(ref allAnimationCurveColumns, removeAt, 1); |
| | 0 | 294 | | DeleteRowsOfTypeInternal(ref allObjectRefColumns, removeAt, 1); |
| | | 295 | | |
| | 0 | 296 | | --rowCount; |
| | 0 | 297 | | dataVersion++; |
| | 0 | 298 | | } |
| | | 299 | | |
| | | 300 | | public void RemoveRows(int removeAt, int numberOfRowsToDelete) |
| | 0 | 301 | | { |
| | 0 | 302 | | int newRowCount = rowCount - numberOfRowsToDelete; |
| | 0 | 303 | | for (int j = removeAt; j < rowCount - numberOfRowsToDelete; j++) |
| | 0 | 304 | | { |
| | 0 | 305 | | allRowNames[j] = allRowNames[j + numberOfRowsToDelete]; |
| | 0 | 306 | | } |
| | | 307 | | |
| | 0 | 308 | | Array.Resize(ref allRowNames, newRowCount); |
| | | 309 | | |
| | 0 | 310 | | DeleteRowsOfTypeInternal(ref allStringColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 311 | | DeleteRowsOfTypeInternal(ref allBoolColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 312 | | DeleteRowsOfTypeInternal(ref allCharColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 313 | | DeleteRowsOfTypeInternal(ref allSbyteColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 314 | | DeleteRowsOfTypeInternal(ref allByteColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 315 | | DeleteRowsOfTypeInternal(ref allShortColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 316 | | DeleteRowsOfTypeInternal(ref allUshortColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 317 | | DeleteRowsOfTypeInternal(ref allIntColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 318 | | DeleteRowsOfTypeInternal(ref allUintColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 319 | | DeleteRowsOfTypeInternal(ref allLongColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 320 | | DeleteRowsOfTypeInternal(ref allUlongColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 321 | | DeleteRowsOfTypeInternal(ref allFloatColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 322 | | DeleteRowsOfTypeInternal(ref allDoubleColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 323 | | DeleteRowsOfTypeInternal(ref allVector2Columns, removeAt, numberOfRowsToDelete); |
| | 0 | 324 | | DeleteRowsOfTypeInternal(ref allVector3Columns, removeAt, numberOfRowsToDelete); |
| | 0 | 325 | | DeleteRowsOfTypeInternal(ref allVector4Columns, removeAt, numberOfRowsToDelete); |
| | 0 | 326 | | DeleteRowsOfTypeInternal(ref allVector2IntColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 327 | | DeleteRowsOfTypeInternal(ref allVector3IntColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 328 | | DeleteRowsOfTypeInternal(ref allQuaternionColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 329 | | DeleteRowsOfTypeInternal(ref allRectColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 330 | | DeleteRowsOfTypeInternal(ref allRectIntColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 331 | | DeleteRowsOfTypeInternal(ref allColorColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 332 | | DeleteRowsOfTypeInternal(ref allLayerMaskColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 333 | | DeleteRowsOfTypeInternal(ref allBoundsColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 334 | | DeleteRowsOfTypeInternal(ref allBoundsIntColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 335 | | DeleteRowsOfTypeInternal(ref allHash128Columns, removeAt, numberOfRowsToDelete); |
| | 0 | 336 | | DeleteRowsOfTypeInternal(ref allGradientColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 337 | | DeleteRowsOfTypeInternal(ref allAnimationCurveColumns, removeAt, numberOfRowsToDelete); |
| | 0 | 338 | | DeleteRowsOfTypeInternal(ref allObjectRefColumns, removeAt, numberOfRowsToDelete); |
| | | 339 | | |
| | 0 | 340 | | rowCount -= numberOfRowsToDelete; |
| | 0 | 341 | | dataVersion++; |
| | 0 | 342 | | } |
| | | 343 | | |
| | | 344 | | |
| | | 345 | | // TODO: Need to make sure that insertAt is the stableID, also this should return the stableID of the newly crea |
| | | 346 | | public int AddColumn(Serializable.SerializableTypes columnType, string columnName, int insertAt = -1) |
| | 0 | 347 | | { |
| | 0 | 348 | | switch (columnType) |
| | | 349 | | { |
| | | 350 | | case Serializable.SerializableTypes.String: |
| | 0 | 351 | | return AddColumnInternal(columnName, ref allStringColumns, Serializable.SerializableTypes.String, in |
| | | 352 | | case Serializable.SerializableTypes.Char: |
| | 0 | 353 | | return AddColumnInternal(columnName, ref allCharColumns, Serializable.SerializableTypes.Char, insert |
| | | 354 | | case Serializable.SerializableTypes.Bool: |
| | 0 | 355 | | return AddColumnInternal(columnName, ref allBoolColumns, Serializable.SerializableTypes.Bool, insert |
| | | 356 | | case Serializable.SerializableTypes.SByte: |
| | 0 | 357 | | return AddColumnInternal(columnName, ref allSbyteColumns, Serializable.SerializableTypes.SByte, inse |
| | | 358 | | case Serializable.SerializableTypes.Byte: |
| | 0 | 359 | | return AddColumnInternal(columnName, ref allByteColumns, Serializable.SerializableTypes.Byte, insert |
| | | 360 | | case Serializable.SerializableTypes.Short: |
| | 0 | 361 | | return AddColumnInternal(columnName, ref allShortColumns, Serializable.SerializableTypes.Short, inse |
| | | 362 | | case Serializable.SerializableTypes.UShort: |
| | 0 | 363 | | return AddColumnInternal(columnName, ref allUshortColumns, Serializable.SerializableTypes.UShort, in |
| | | 364 | | case Serializable.SerializableTypes.Int: |
| | 0 | 365 | | return AddColumnInternal(columnName, ref allIntColumns, Serializable.SerializableTypes.Int, insertAt |
| | | 366 | | case Serializable.SerializableTypes.UInt: |
| | 0 | 367 | | return AddColumnInternal(columnName, ref allUintColumns, Serializable.SerializableTypes.UInt, insert |
| | | 368 | | case Serializable.SerializableTypes.Long: |
| | 0 | 369 | | return AddColumnInternal(columnName, ref allLongColumns, Serializable.SerializableTypes.Long, insert |
| | | 370 | | case Serializable.SerializableTypes.ULong: |
| | 0 | 371 | | return AddColumnInternal(columnName, ref allUlongColumns, Serializable.SerializableTypes.ULong, inse |
| | | 372 | | case Serializable.SerializableTypes.Float: |
| | 0 | 373 | | return AddColumnInternal(columnName, ref allFloatColumns, Serializable.SerializableTypes.Float, inse |
| | | 374 | | case Serializable.SerializableTypes.Double: |
| | 0 | 375 | | return AddColumnInternal(columnName, ref allDoubleColumns, Serializable.SerializableTypes.Double, in |
| | | 376 | | case Serializable.SerializableTypes.Vector2: |
| | 0 | 377 | | return AddColumnInternal(columnName, ref allVector2Columns, Serializable.SerializableTypes.Vector2, |
| | | 378 | | case Serializable.SerializableTypes.Vector3: |
| | 0 | 379 | | return AddColumnInternal(columnName, ref allVector3Columns, Serializable.SerializableTypes.Vector3, |
| | | 380 | | case Serializable.SerializableTypes.Vector4: |
| | 0 | 381 | | return AddColumnInternal(columnName, ref allVector4Columns, Serializable.SerializableTypes.Vector4, |
| | | 382 | | case Serializable.SerializableTypes.Vector2Int: |
| | 0 | 383 | | return AddColumnInternal(columnName, ref allVector2IntColumns, Serializable.SerializableTypes.Vector |
| | | 384 | | case Serializable.SerializableTypes.Vector3Int: |
| | 0 | 385 | | return AddColumnInternal(columnName, ref allVector3IntColumns, Serializable.SerializableTypes.Vector |
| | | 386 | | case Serializable.SerializableTypes.Quaternion: |
| | 0 | 387 | | return AddColumnInternal(columnName, ref allQuaternionColumns, Serializable.SerializableTypes.Quater |
| | | 388 | | case Serializable.SerializableTypes.Rect: |
| | 0 | 389 | | return AddColumnInternal(columnName, ref allRectColumns, Serializable.SerializableTypes.Rect, insert |
| | | 390 | | case Serializable.SerializableTypes.RectInt: |
| | 0 | 391 | | return AddColumnInternal(columnName, ref allRectIntColumns, Serializable.SerializableTypes.RectInt, |
| | | 392 | | case Serializable.SerializableTypes.Color: |
| | 0 | 393 | | return AddColumnInternal(columnName, ref allColorColumns, Serializable.SerializableTypes.Color, inse |
| | | 394 | | case Serializable.SerializableTypes.LayerMask: |
| | 0 | 395 | | return AddColumnInternal(columnName, ref allLayerMaskColumns, Serializable.SerializableTypes.LayerMa |
| | | 396 | | case Serializable.SerializableTypes.Bounds: |
| | 0 | 397 | | return AddColumnInternal(columnName, ref allBoundsColumns, Serializable.SerializableTypes.Bounds, in |
| | | 398 | | case Serializable.SerializableTypes.BoundsInt: |
| | 0 | 399 | | return AddColumnInternal(columnName, ref allBoundsIntColumns, Serializable.SerializableTypes.BoundsI |
| | | 400 | | case Serializable.SerializableTypes.Hash128: |
| | 0 | 401 | | return AddColumnInternal(columnName, ref allHash128Columns, Serializable.SerializableTypes.Hash128, |
| | | 402 | | case Serializable.SerializableTypes.Gradient: |
| | 0 | 403 | | return AddColumnInternal(columnName, ref allGradientColumns, Serializable.SerializableTypes.Gradient |
| | | 404 | | case Serializable.SerializableTypes.AnimationCurve: |
| | 0 | 405 | | return AddColumnInternal(columnName, ref allAnimationCurveColumns, Serializable.SerializableTypes.An |
| | | 406 | | case Serializable.SerializableTypes.Object: |
| | 0 | 407 | | return AddColumnInternal(columnName, ref allObjectRefColumns, Serializable.SerializableTypes.Object, |
| | | 408 | | } |
| | 0 | 409 | | return -1; |
| | 0 | 410 | | } |
| | | 411 | | |
| | | 412 | | // TODO: need to make sure this is the stable ID? |
| | | 413 | | public void RemoveColumn(Serializable.SerializableTypes columnType, int removeAt = -1) |
| | 0 | 414 | | { |
| | 0 | 415 | | switch (columnType) |
| | | 416 | | { |
| | | 417 | | case Serializable.SerializableTypes.String: |
| | 0 | 418 | | RemoveColumnInternal(ref allStringColumns, Serializable.SerializableTypes.String, removeAt); |
| | 0 | 419 | | break; |
| | | 420 | | case Serializable.SerializableTypes.Char: |
| | 0 | 421 | | RemoveColumnInternal(ref allCharColumns, Serializable.SerializableTypes.Char, removeAt); |
| | 0 | 422 | | break; |
| | | 423 | | case Serializable.SerializableTypes.Bool: |
| | 0 | 424 | | RemoveColumnInternal(ref allBoolColumns, Serializable.SerializableTypes.Bool, removeAt); |
| | 0 | 425 | | break; |
| | | 426 | | case Serializable.SerializableTypes.SByte: |
| | 0 | 427 | | RemoveColumnInternal(ref allSbyteColumns, Serializable.SerializableTypes.SByte, removeAt); |
| | 0 | 428 | | break; |
| | | 429 | | case Serializable.SerializableTypes.Byte: |
| | 0 | 430 | | RemoveColumnInternal(ref allByteColumns, Serializable.SerializableTypes.Byte, removeAt); |
| | 0 | 431 | | break; |
| | | 432 | | case Serializable.SerializableTypes.Short: |
| | 0 | 433 | | RemoveColumnInternal(ref allShortColumns, Serializable.SerializableTypes.Short, removeAt); |
| | 0 | 434 | | break; |
| | | 435 | | case Serializable.SerializableTypes.UShort: |
| | 0 | 436 | | RemoveColumnInternal(ref allUshortColumns, Serializable.SerializableTypes.UShort, removeAt); |
| | 0 | 437 | | break; |
| | | 438 | | case Serializable.SerializableTypes.Int: |
| | 0 | 439 | | RemoveColumnInternal(ref allIntColumns, Serializable.SerializableTypes.Int, removeAt); |
| | 0 | 440 | | break; |
| | | 441 | | case Serializable.SerializableTypes.UInt: |
| | 0 | 442 | | RemoveColumnInternal(ref allUintColumns, Serializable.SerializableTypes.UInt, removeAt); |
| | 0 | 443 | | break; |
| | | 444 | | case Serializable.SerializableTypes.Long: |
| | 0 | 445 | | RemoveColumnInternal(ref allLongColumns, Serializable.SerializableTypes.Long, removeAt); |
| | 0 | 446 | | break; |
| | | 447 | | case Serializable.SerializableTypes.ULong: |
| | 0 | 448 | | RemoveColumnInternal(ref allUlongColumns, Serializable.SerializableTypes.ULong, removeAt); |
| | 0 | 449 | | break; |
| | | 450 | | case Serializable.SerializableTypes.Float: |
| | 0 | 451 | | RemoveColumnInternal(ref allFloatColumns, Serializable.SerializableTypes.Float, removeAt); |
| | 0 | 452 | | break; |
| | | 453 | | case Serializable.SerializableTypes.Double: |
| | 0 | 454 | | RemoveColumnInternal(ref allDoubleColumns, Serializable.SerializableTypes.Double, removeAt); |
| | 0 | 455 | | break; |
| | | 456 | | case Serializable.SerializableTypes.Vector2: |
| | 0 | 457 | | RemoveColumnInternal(ref allVector2Columns, Serializable.SerializableTypes.Vector2, removeAt); |
| | 0 | 458 | | break; |
| | | 459 | | case Serializable.SerializableTypes.Vector3: |
| | 0 | 460 | | RemoveColumnInternal(ref allVector3Columns, Serializable.SerializableTypes.Vector3, removeAt); |
| | 0 | 461 | | break; |
| | | 462 | | case Serializable.SerializableTypes.Vector4: |
| | 0 | 463 | | RemoveColumnInternal(ref allVector4Columns, Serializable.SerializableTypes.Vector4, removeAt); |
| | 0 | 464 | | break; |
| | | 465 | | case Serializable.SerializableTypes.Vector2Int: |
| | 0 | 466 | | RemoveColumnInternal(ref allVector2IntColumns, Serializable.SerializableTypes.Vector2Int, removeAt); |
| | 0 | 467 | | break; |
| | | 468 | | case Serializable.SerializableTypes.Vector3Int: |
| | 0 | 469 | | RemoveColumnInternal(ref allVector3IntColumns, Serializable.SerializableTypes.Vector3Int, removeAt); |
| | 0 | 470 | | break; |
| | | 471 | | case Serializable.SerializableTypes.Quaternion: |
| | 0 | 472 | | RemoveColumnInternal(ref allQuaternionColumns, Serializable.SerializableTypes.Quaternion, removeAt); |
| | 0 | 473 | | break; |
| | | 474 | | case Serializable.SerializableTypes.Rect: |
| | 0 | 475 | | RemoveColumnInternal(ref allRectColumns, Serializable.SerializableTypes.Rect, removeAt); |
| | 0 | 476 | | break; |
| | | 477 | | case Serializable.SerializableTypes.RectInt: |
| | 0 | 478 | | RemoveColumnInternal(ref allRectIntColumns, Serializable.SerializableTypes.RectInt, removeAt); |
| | 0 | 479 | | break; |
| | | 480 | | case Serializable.SerializableTypes.Color: |
| | 0 | 481 | | RemoveColumnInternal(ref allColorColumns, Serializable.SerializableTypes.Color, removeAt); |
| | 0 | 482 | | break; |
| | | 483 | | case Serializable.SerializableTypes.LayerMask: |
| | 0 | 484 | | RemoveColumnInternal(ref allLayerMaskColumns, Serializable.SerializableTypes.LayerMask, removeAt); |
| | 0 | 485 | | break; |
| | | 486 | | case Serializable.SerializableTypes.Bounds: |
| | 0 | 487 | | RemoveColumnInternal(ref allBoundsColumns, Serializable.SerializableTypes.Bounds, removeAt); |
| | 0 | 488 | | break; |
| | | 489 | | case Serializable.SerializableTypes.BoundsInt: |
| | 0 | 490 | | RemoveColumnInternal(ref allBoundsIntColumns, Serializable.SerializableTypes.BoundsInt, removeAt); |
| | 0 | 491 | | break; |
| | | 492 | | case Serializable.SerializableTypes.Hash128: |
| | 0 | 493 | | RemoveColumnInternal(ref allHash128Columns, Serializable.SerializableTypes.Hash128, removeAt); |
| | 0 | 494 | | break; |
| | | 495 | | case Serializable.SerializableTypes.Gradient: |
| | 0 | 496 | | RemoveColumnInternal(ref allGradientColumns, Serializable.SerializableTypes.Gradient, removeAt); |
| | 0 | 497 | | break; |
| | | 498 | | case Serializable.SerializableTypes.AnimationCurve: |
| | 0 | 499 | | RemoveColumnInternal(ref allAnimationCurveColumns, Serializable.SerializableTypes.AnimationCurve, re |
| | 0 | 500 | | break; |
| | | 501 | | case Serializable.SerializableTypes.Object: |
| | 0 | 502 | | RemoveColumnInternal(ref allObjectRefColumns, Serializable.SerializableTypes.Object, removeAt); |
| | 0 | 503 | | break; |
| | | 504 | | } |
| | 0 | 505 | | } |
| | | 506 | | |
| | | 507 | | |
| | | 508 | | |
| | | 509 | | |
| | | 510 | | // Set |
| | | 511 | | |
| | | 512 | | public ulong SetString(int row, int column, string value) |
| | 0 | 513 | | { |
| | 0 | 514 | | return SetCell(row, column, ref allStringColumns, value); |
| | 0 | 515 | | } |
| | | 516 | | |
| | | 517 | | public ulong SetBool(int row, int column, bool value) |
| | 0 | 518 | | { |
| | 0 | 519 | | return SetCell(row, column, ref allBoolColumns, value); |
| | 0 | 520 | | } |
| | | 521 | | |
| | | 522 | | public ulong SetChar(int row, int column, char value) |
| | 0 | 523 | | { |
| | 0 | 524 | | return SetCell(row, column, ref allCharColumns, value); |
| | 0 | 525 | | } |
| | | 526 | | |
| | | 527 | | public ulong SetSByte(int row, int column, sbyte value) |
| | 0 | 528 | | { |
| | 0 | 529 | | return SetCell(row, column, ref allSbyteColumns, value); |
| | 0 | 530 | | } |
| | | 531 | | |
| | | 532 | | public ulong SetByte(int row, int column, byte value) |
| | 0 | 533 | | { |
| | 0 | 534 | | return SetCell(row, column, ref allByteColumns, value); |
| | 0 | 535 | | } |
| | | 536 | | |
| | | 537 | | public ulong SetShort(int row, int column, short value) |
| | 0 | 538 | | { |
| | 0 | 539 | | return SetCell(row, column, ref allShortColumns, value); |
| | 0 | 540 | | } |
| | | 541 | | |
| | | 542 | | public ulong SetUShort(int row, int column, ushort value) |
| | 0 | 543 | | { |
| | 0 | 544 | | return SetCell(row, column, ref allUshortColumns, value); |
| | 0 | 545 | | } |
| | | 546 | | |
| | | 547 | | public ulong SetInt(int row, int column, int value) |
| | 0 | 548 | | { |
| | 0 | 549 | | return SetCell(row, column, ref allIntColumns, value); |
| | 0 | 550 | | } |
| | | 551 | | |
| | | 552 | | public ulong SetUInt(int row, int column, uint value) |
| | 0 | 553 | | { |
| | 0 | 554 | | return SetCell(row, column, ref allUintColumns, value); |
| | 0 | 555 | | } |
| | | 556 | | |
| | | 557 | | public ulong SetLong(int row, int column, long value) |
| | 0 | 558 | | { |
| | 0 | 559 | | return SetCell(row, column, ref allLongColumns, value); |
| | 0 | 560 | | } |
| | | 561 | | |
| | | 562 | | public ulong SetULong(int row, int column, ulong value) |
| | 0 | 563 | | { |
| | 0 | 564 | | return SetCell(row, column, ref allUlongColumns, value); |
| | 0 | 565 | | } |
| | | 566 | | |
| | | 567 | | public ulong SetFloat(int row, int column, float value) |
| | 0 | 568 | | { |
| | 0 | 569 | | return SetCell(row, column, ref allFloatColumns, value); |
| | 0 | 570 | | } |
| | | 571 | | |
| | | 572 | | public ulong SetDouble(int row, int column, double value) |
| | 0 | 573 | | { |
| | 0 | 574 | | return SetCell(row, column, ref allDoubleColumns, value); |
| | 0 | 575 | | } |
| | | 576 | | |
| | | 577 | | public ulong SetVector2(int row, int column, Vector2 value) |
| | 0 | 578 | | { |
| | 0 | 579 | | return SetCell(row, column, ref allVector2Columns, value); |
| | 0 | 580 | | } |
| | | 581 | | |
| | | 582 | | public ulong SetVector3(int row, int column, Vector3 value) |
| | 0 | 583 | | { |
| | 0 | 584 | | return SetCell(row, column, ref allVector3Columns, value); |
| | 0 | 585 | | } |
| | | 586 | | |
| | | 587 | | public ulong SetVector4(int row, int column, Vector4 value) |
| | 0 | 588 | | { |
| | 0 | 589 | | return SetCell(row, column, ref allVector4Columns, value); |
| | 0 | 590 | | } |
| | | 591 | | |
| | | 592 | | public ulong SetVector2Int(int row, int column, Vector2Int value) |
| | 0 | 593 | | { |
| | 0 | 594 | | return SetCell(row, column, ref allVector2IntColumns, value); |
| | 0 | 595 | | } |
| | | 596 | | |
| | | 597 | | public ulong SetVector3Int(int row, int column, Vector3Int value) |
| | 0 | 598 | | { |
| | 0 | 599 | | return SetCell(row, column, ref allVector3IntColumns, value); |
| | 0 | 600 | | } |
| | | 601 | | |
| | | 602 | | public ulong SetQuaternion(int row, int column, Quaternion value) |
| | 0 | 603 | | { |
| | 0 | 604 | | return SetCell(row, column, ref allQuaternionColumns, value); |
| | 0 | 605 | | } |
| | | 606 | | |
| | | 607 | | public ulong SetRect(int row, int column, Rect value) |
| | 0 | 608 | | { |
| | 0 | 609 | | return SetCell(row, column, ref allRectColumns, value); |
| | 0 | 610 | | } |
| | | 611 | | |
| | | 612 | | public ulong SetRectInt(int row, int column, RectInt value) |
| | 0 | 613 | | { |
| | 0 | 614 | | return SetCell(row, column, ref allRectIntColumns, value); |
| | 0 | 615 | | } |
| | | 616 | | |
| | | 617 | | public ulong SetColor(int row, int column, Color value) |
| | 0 | 618 | | { |
| | 0 | 619 | | return SetCell(row, column, ref allColorColumns, value); |
| | 0 | 620 | | } |
| | | 621 | | |
| | | 622 | | public ulong SetLayerMask(int row, int column, LayerMask value) |
| | 0 | 623 | | { |
| | 0 | 624 | | return SetCell(row, column, ref allLayerMaskColumns, value); |
| | 0 | 625 | | } |
| | | 626 | | |
| | | 627 | | public ulong SetBounds(int row, int column, Bounds value) |
| | 0 | 628 | | { |
| | 0 | 629 | | return SetCell(row, column, ref allBoundsColumns, value); |
| | 0 | 630 | | } |
| | | 631 | | |
| | | 632 | | public ulong SetBoundsInt(int row, int column, BoundsInt value) |
| | 0 | 633 | | { |
| | 0 | 634 | | return SetCell(row, column, ref allBoundsIntColumns, value); |
| | 0 | 635 | | } |
| | | 636 | | |
| | | 637 | | public ulong SetHash128(int row, int column, Hash128 value) |
| | 0 | 638 | | { |
| | 0 | 639 | | return SetCell(row, column, ref allHash128Columns, value); |
| | 0 | 640 | | } |
| | | 641 | | |
| | | 642 | | public ulong SetGradient(int row, int column, Gradient value) |
| | 0 | 643 | | { |
| | 0 | 644 | | return SetCell(row, column, ref allGradientColumns, value); |
| | 0 | 645 | | } |
| | | 646 | | |
| | | 647 | | public ulong SetAnimationCurve(int row, int column, AnimationCurve value) |
| | 0 | 648 | | { |
| | 0 | 649 | | return SetCell(row, column, ref allAnimationCurveColumns, value); |
| | 0 | 650 | | } |
| | | 651 | | |
| | | 652 | | public ulong SetObject(int row, int column, UnityEngine.Object value) |
| | 0 | 653 | | { |
| | 0 | 654 | | return SetCell(row, column, ref allObjectRefColumns, value); |
| | 0 | 655 | | } |
| | | 656 | | |
| | | 657 | | // Get |
| | | 658 | | public string GetString(int row, int column) |
| | 0 | 659 | | { |
| | 0 | 660 | | return GetCell(row, column, ref allStringColumns); |
| | 0 | 661 | | } |
| | | 662 | | |
| | | 663 | | public bool GetBool(int row, int column) |
| | 0 | 664 | | { |
| | 0 | 665 | | return GetCell(row, column, ref allBoolColumns); |
| | 0 | 666 | | } |
| | | 667 | | |
| | | 668 | | public char GetChar(int row, int column) |
| | 0 | 669 | | { |
| | 0 | 670 | | return GetCell(row, column, ref allCharColumns); |
| | 0 | 671 | | } |
| | | 672 | | |
| | | 673 | | public sbyte GetSByte(int row, int column) |
| | 0 | 674 | | { |
| | 0 | 675 | | return GetCell(row, column, ref allSbyteColumns); |
| | 0 | 676 | | } |
| | | 677 | | |
| | | 678 | | public byte GetByte(int row, int column) |
| | 0 | 679 | | { |
| | 0 | 680 | | return GetCell(row, column, ref allByteColumns); |
| | 0 | 681 | | } |
| | | 682 | | |
| | | 683 | | public short GetShort(int row, int column) |
| | 0 | 684 | | { |
| | 0 | 685 | | return GetCell(row, column, ref allShortColumns); |
| | 0 | 686 | | } |
| | | 687 | | |
| | | 688 | | public ushort GetUShort(int row, int column) |
| | 0 | 689 | | { |
| | 0 | 690 | | return GetCell(row, column, ref allUshortColumns); |
| | 0 | 691 | | } |
| | | 692 | | |
| | | 693 | | public int GetInt(int row, int column) |
| | 0 | 694 | | { |
| | 0 | 695 | | return GetCell(row, column, ref allIntColumns); |
| | 0 | 696 | | } |
| | | 697 | | |
| | | 698 | | public uint GetUInt(int row, int column) |
| | 0 | 699 | | { |
| | 0 | 700 | | return GetCell(row, column, ref allUintColumns); |
| | 0 | 701 | | } |
| | | 702 | | |
| | | 703 | | public long GetLong(int row, int column) |
| | 0 | 704 | | { |
| | 0 | 705 | | return GetCell(row, column, ref allLongColumns); |
| | 0 | 706 | | } |
| | | 707 | | |
| | | 708 | | public ulong GetULong(int row, int column) |
| | 0 | 709 | | { |
| | 0 | 710 | | return GetCell(row, column, ref allUlongColumns); |
| | 0 | 711 | | } |
| | | 712 | | |
| | | 713 | | public float GetFloat(int row, int column) |
| | 0 | 714 | | { |
| | 0 | 715 | | return GetCell(row, column, ref allFloatColumns); |
| | 0 | 716 | | } |
| | | 717 | | |
| | | 718 | | public double GetDouble(int row, int column) |
| | 0 | 719 | | { |
| | 0 | 720 | | return GetCell(row, column, ref allDoubleColumns); |
| | 0 | 721 | | } |
| | | 722 | | |
| | | 723 | | public Vector2 GetVector2(int row, int column) |
| | 0 | 724 | | { |
| | 0 | 725 | | return GetCell(row, column, ref allVector2Columns); |
| | 0 | 726 | | } |
| | | 727 | | |
| | | 728 | | public Vector3 GetVector3(int row, int column) |
| | 0 | 729 | | { |
| | 0 | 730 | | return GetCell(row, column, ref allVector3Columns); |
| | 0 | 731 | | } |
| | | 732 | | |
| | | 733 | | public Vector4 GetVector4(int row, int column) |
| | 0 | 734 | | { |
| | 0 | 735 | | return GetCell(row, column, ref allVector4Columns); |
| | 0 | 736 | | } |
| | | 737 | | |
| | | 738 | | public Vector2Int GetVector2Int(int row, int column) |
| | 0 | 739 | | { |
| | 0 | 740 | | return GetCell(row, column, ref allVector2IntColumns); |
| | 0 | 741 | | } |
| | | 742 | | |
| | | 743 | | public Vector3Int GetVector3Int(int row, int column) |
| | 0 | 744 | | { |
| | 0 | 745 | | return GetCell(row, column, ref allVector3IntColumns); |
| | 0 | 746 | | } |
| | | 747 | | |
| | | 748 | | public Quaternion GetQuaternion(int row, int column) |
| | 0 | 749 | | { |
| | 0 | 750 | | return GetCell(row, column, ref allQuaternionColumns); |
| | 0 | 751 | | } |
| | | 752 | | |
| | | 753 | | public Rect GetRect(int row, int column) |
| | 0 | 754 | | { |
| | 0 | 755 | | return GetCell(row, column, ref allRectColumns); |
| | 0 | 756 | | } |
| | | 757 | | |
| | | 758 | | public RectInt GetRectInt(int row, int column) |
| | 0 | 759 | | { |
| | 0 | 760 | | return GetCell(row, column, ref allRectIntColumns); |
| | 0 | 761 | | } |
| | | 762 | | |
| | | 763 | | public Color GetColor(int row, int column) |
| | 0 | 764 | | { |
| | 0 | 765 | | return GetCell(row, column, ref allColorColumns); |
| | 0 | 766 | | } |
| | | 767 | | |
| | | 768 | | public LayerMask GetLayerMask(int row, int column) |
| | 0 | 769 | | { |
| | 0 | 770 | | return GetCell(row, column, ref allLayerMaskColumns); |
| | 0 | 771 | | } |
| | | 772 | | |
| | | 773 | | public Bounds GetBounds(int row, int column) |
| | 0 | 774 | | { |
| | 0 | 775 | | return GetCell(row, column, ref allBoundsColumns); |
| | 0 | 776 | | } |
| | | 777 | | |
| | | 778 | | public BoundsInt GetBoundsInt(int row, int column) |
| | 0 | 779 | | { |
| | 0 | 780 | | return GetCell(row, column, ref allBoundsIntColumns); |
| | 0 | 781 | | } |
| | | 782 | | |
| | | 783 | | public Hash128 GetHash128(int row, int column) |
| | 0 | 784 | | { |
| | 0 | 785 | | return GetCell(row, column, ref allHash128Columns); |
| | 0 | 786 | | } |
| | | 787 | | |
| | | 788 | | public Gradient GetGradient(int row, int column) |
| | 0 | 789 | | { |
| | 0 | 790 | | return GetCell(row, column, ref allGradientColumns); |
| | 0 | 791 | | } |
| | | 792 | | |
| | | 793 | | public AnimationCurve GetAnimationCurve(int row, int column) |
| | 0 | 794 | | { |
| | 0 | 795 | | return GetCell(row, column, ref allAnimationCurveColumns); |
| | 0 | 796 | | } |
| | | 797 | | |
| | | 798 | | public UnityEngine.Object GetObject(int row, int column) |
| | 0 | 799 | | { |
| | 0 | 800 | | return GetCell(row, column, ref allObjectRefColumns); |
| | 0 | 801 | | } |
| | | 802 | | |
| | | 803 | | // Get ref |
| | | 804 | | |
| | | 805 | | public ref string GetStringRef(int row, int column) |
| | 0 | 806 | | { |
| | 0 | 807 | | return ref GetCellRef(row, column, ref allStringColumns); |
| | 0 | 808 | | } |
| | | 809 | | |
| | | 810 | | public ref bool GetBoolRef(int row, int column) |
| | 0 | 811 | | { |
| | 0 | 812 | | return ref GetCellRef(row, column, ref allBoolColumns); |
| | 0 | 813 | | } |
| | | 814 | | |
| | | 815 | | public ref char GetCharRef(int row, int column) |
| | 0 | 816 | | { |
| | 0 | 817 | | return ref GetCellRef(row, column, ref allCharColumns); |
| | 0 | 818 | | } |
| | | 819 | | |
| | | 820 | | public ref sbyte GetSbyteRef(int row, int column) |
| | 0 | 821 | | { |
| | 0 | 822 | | return ref GetCellRef(row, column, ref allSbyteColumns); |
| | 0 | 823 | | } |
| | | 824 | | |
| | | 825 | | public ref byte GetByteRef(int row, int columnID) |
| | 0 | 826 | | { |
| | 0 | 827 | | return ref GetCellRef(row, columnID, ref allByteColumns); |
| | 0 | 828 | | } |
| | | 829 | | |
| | | 830 | | public ref short GetShortRef(int row, int column) |
| | 0 | 831 | | { |
| | 0 | 832 | | return ref GetCellRef(row, column, ref allShortColumns); |
| | 0 | 833 | | } |
| | | 834 | | |
| | | 835 | | public ref ushort GetUshortRef(int row, int column) |
| | 0 | 836 | | { |
| | 0 | 837 | | return ref GetCellRef(row, column, ref allUshortColumns); |
| | 0 | 838 | | } |
| | | 839 | | |
| | | 840 | | public ref int GetIntRef(int row, int column) |
| | 0 | 841 | | { |
| | 0 | 842 | | return ref GetCellRef(row, column, ref allIntColumns); |
| | 0 | 843 | | } |
| | | 844 | | |
| | | 845 | | public ref uint GetUintRef(int row, int column) |
| | 0 | 846 | | { |
| | 0 | 847 | | return ref GetCellRef(row, column, ref allUintColumns); |
| | 0 | 848 | | } |
| | | 849 | | |
| | | 850 | | public ref long GetLongRef(int row, int column) |
| | 0 | 851 | | { |
| | 0 | 852 | | return ref GetCellRef(row, column, ref allLongColumns); |
| | 0 | 853 | | } |
| | | 854 | | |
| | | 855 | | public ref ulong GetUlongRef(int row, int column) |
| | 0 | 856 | | { |
| | 0 | 857 | | return ref GetCellRef(row, column, ref allUlongColumns); |
| | 0 | 858 | | } |
| | | 859 | | |
| | | 860 | | public ref float GetFloatRef(int row, int column) |
| | 0 | 861 | | { |
| | 0 | 862 | | return ref GetCellRef(row, column, ref allFloatColumns); |
| | 0 | 863 | | } |
| | | 864 | | |
| | | 865 | | public ref double GetDoubleRef(int row, int column) |
| | 0 | 866 | | { |
| | 0 | 867 | | return ref GetCellRef(row, column, ref allDoubleColumns); |
| | 0 | 868 | | } |
| | | 869 | | |
| | | 870 | | public ref Vector2 GetVector2Ref(int row, int column) |
| | 0 | 871 | | { |
| | 0 | 872 | | return ref GetCellRef(row, column, ref allVector2Columns); |
| | 0 | 873 | | } |
| | | 874 | | |
| | | 875 | | public ref Vector3 GetVector3Ref(int row, int column) |
| | 0 | 876 | | { |
| | 0 | 877 | | return ref GetCellRef(row, column, ref allVector3Columns); |
| | 0 | 878 | | } |
| | | 879 | | |
| | | 880 | | public ref Vector4 GetVector4Ref(int row, int column) |
| | 0 | 881 | | { |
| | 0 | 882 | | return ref GetCellRef(row, column, ref allVector4Columns); |
| | 0 | 883 | | } |
| | | 884 | | |
| | | 885 | | public ref Vector2Int GetVector2IntRef(int row, int column) |
| | 0 | 886 | | { |
| | 0 | 887 | | return ref GetCellRef(row, column, ref allVector2IntColumns); |
| | 0 | 888 | | } |
| | | 889 | | |
| | | 890 | | public ref Vector3Int GetVector3IntRef(int row, int column) |
| | 0 | 891 | | { |
| | 0 | 892 | | return ref GetCellRef(row, column, ref allVector3IntColumns); |
| | 0 | 893 | | } |
| | | 894 | | |
| | | 895 | | public ref Quaternion GetQuaternionRef(int row, int column) |
| | 0 | 896 | | { |
| | 0 | 897 | | return ref GetCellRef(row, column, ref allQuaternionColumns); |
| | 0 | 898 | | } |
| | | 899 | | |
| | | 900 | | public ref Rect GetRectRef(int row, int column) |
| | 0 | 901 | | { |
| | 0 | 902 | | return ref GetCellRef(row, column, ref allRectColumns); |
| | 0 | 903 | | } |
| | | 904 | | |
| | | 905 | | public ref RectInt GetRectIntRef(int row, int column) |
| | 0 | 906 | | { |
| | 0 | 907 | | return ref GetCellRef(row, column, ref allRectIntColumns); |
| | 0 | 908 | | } |
| | | 909 | | |
| | | 910 | | public ref Color GetColorRef(int row, int column) |
| | 0 | 911 | | { |
| | 0 | 912 | | return ref GetCellRef(row, column, ref allColorColumns); |
| | 0 | 913 | | } |
| | | 914 | | |
| | | 915 | | public ref LayerMask GetLayerMaskRef(int row, int column) |
| | 0 | 916 | | { |
| | 0 | 917 | | return ref GetCellRef(row, column, ref allLayerMaskColumns); |
| | 0 | 918 | | } |
| | | 919 | | |
| | | 920 | | public ref Bounds GetBoundsRef(int row, int column) |
| | 0 | 921 | | { |
| | 0 | 922 | | return ref GetCellRef(row, column, ref allBoundsColumns); |
| | 0 | 923 | | } |
| | | 924 | | |
| | | 925 | | public ref BoundsInt GetBoundsIntRef(int row, int column) |
| | 0 | 926 | | { |
| | 0 | 927 | | return ref GetCellRef(row, column, ref allBoundsIntColumns); |
| | 0 | 928 | | } |
| | | 929 | | |
| | | 930 | | public ref Hash128 GetHash128Ref(int row, int column) |
| | 0 | 931 | | { |
| | 0 | 932 | | return ref GetCellRef(row, column, ref allHash128Columns); |
| | 0 | 933 | | } |
| | | 934 | | |
| | | 935 | | public ref Gradient GetGradientRef(int row, int column) |
| | 0 | 936 | | { |
| | 0 | 937 | | return ref GetCellRef(row, column, ref allGradientColumns); |
| | 0 | 938 | | } |
| | | 939 | | |
| | | 940 | | public ref AnimationCurve GetAnimationCurveRef(int row, int column) |
| | 0 | 941 | | { |
| | 0 | 942 | | return ref GetCellRef(row, column, ref allAnimationCurveColumns); |
| | 0 | 943 | | } |
| | | 944 | | |
| | | 945 | | public ref UnityEngine.Object GetObjectRef(int row, int column) |
| | 0 | 946 | | { |
| | 0 | 947 | | return ref GetCellRef(row, column, ref allObjectRefColumns); |
| | 0 | 948 | | } |
| | | 949 | | |
| | | 950 | | // Get Column |
| | | 951 | | |
| | | 952 | | public string[] GetStringColumn(int column) |
| | 0 | 953 | | { |
| | 0 | 954 | | return GetColumn(column, ref allStringColumns); |
| | 0 | 955 | | } |
| | | 956 | | |
| | | 957 | | public bool[] GetBoolColumn(int column) |
| | 0 | 958 | | { |
| | 0 | 959 | | return GetColumn(column, ref allBoolColumns); |
| | 0 | 960 | | } |
| | | 961 | | |
| | | 962 | | public char[] GetCharColumn(int column) |
| | 0 | 963 | | { |
| | 0 | 964 | | return GetColumn(column, ref allCharColumns); |
| | 0 | 965 | | } |
| | | 966 | | |
| | | 967 | | public sbyte[] GetSbyteColumn(int column) |
| | 0 | 968 | | { |
| | 0 | 969 | | return GetColumn(column, ref allSbyteColumns); |
| | 0 | 970 | | } |
| | | 971 | | |
| | | 972 | | public byte[] GetByteColumn(int column) |
| | 0 | 973 | | { |
| | 0 | 974 | | return GetColumn(column, ref allByteColumns); |
| | 0 | 975 | | } |
| | | 976 | | |
| | | 977 | | public short[] GetShortColumn(int column) |
| | 0 | 978 | | { |
| | 0 | 979 | | return GetColumn(column, ref allShortColumns); |
| | 0 | 980 | | } |
| | | 981 | | |
| | | 982 | | public ushort[] GetUshortColumn(int column) |
| | 0 | 983 | | { |
| | 0 | 984 | | return GetColumn(column, ref allUshortColumns); |
| | 0 | 985 | | } |
| | | 986 | | |
| | | 987 | | public int[] GetIntColumn(int column) |
| | 0 | 988 | | { |
| | 0 | 989 | | return GetColumn(column, ref allIntColumns); |
| | 0 | 990 | | } |
| | | 991 | | |
| | | 992 | | public uint[] GetUintColumn(int column) |
| | 0 | 993 | | { |
| | 0 | 994 | | return GetColumn(column, ref allUintColumns); |
| | 0 | 995 | | } |
| | | 996 | | |
| | | 997 | | public long[] GetLongColumn(int column) |
| | 0 | 998 | | { |
| | 0 | 999 | | return GetColumn(column, ref allLongColumns); |
| | 0 | 1000 | | } |
| | | 1001 | | |
| | | 1002 | | public ulong[] GetUlongColumn(int column) |
| | 0 | 1003 | | { |
| | 0 | 1004 | | return GetColumn(column, ref allUlongColumns); |
| | 0 | 1005 | | } |
| | | 1006 | | |
| | | 1007 | | public float[] GetFloatColumn(int column) |
| | 0 | 1008 | | { |
| | 0 | 1009 | | return GetColumn(column, ref allFloatColumns); |
| | 0 | 1010 | | } |
| | | 1011 | | |
| | | 1012 | | public double[] GetDoubleColumn(int column) |
| | 0 | 1013 | | { |
| | 0 | 1014 | | return GetColumn(column, ref allDoubleColumns); |
| | 0 | 1015 | | } |
| | | 1016 | | |
| | | 1017 | | public Vector2[] GetVector2Column(int column) |
| | 0 | 1018 | | { |
| | 0 | 1019 | | return GetColumn(column, ref allVector2Columns); |
| | 0 | 1020 | | } |
| | | 1021 | | |
| | | 1022 | | public Vector3[] GetVector3Column(int column) |
| | 0 | 1023 | | { |
| | 0 | 1024 | | return GetColumn(column, ref allVector3Columns); |
| | 0 | 1025 | | } |
| | | 1026 | | |
| | | 1027 | | public Vector4[] GetVector4Column(int column) |
| | 0 | 1028 | | { |
| | 0 | 1029 | | return GetColumn(column, ref allVector4Columns); |
| | 0 | 1030 | | } |
| | | 1031 | | |
| | | 1032 | | public Vector2Int[] GetVector2IntColumn(int column) |
| | 0 | 1033 | | { |
| | 0 | 1034 | | return GetColumn(column, ref allVector2IntColumns); |
| | 0 | 1035 | | } |
| | | 1036 | | |
| | | 1037 | | public Vector3Int[] GetVector3IntColumn(int column) |
| | 0 | 1038 | | { |
| | 0 | 1039 | | return GetColumn(column, ref allVector3IntColumns); |
| | 0 | 1040 | | } |
| | | 1041 | | |
| | | 1042 | | public Quaternion[] GetQuaternionColumn(int column) |
| | 0 | 1043 | | { |
| | 0 | 1044 | | return GetColumn(column, ref allQuaternionColumns); |
| | 0 | 1045 | | } |
| | | 1046 | | |
| | | 1047 | | public Rect[] GetRectColumn(int column) |
| | 0 | 1048 | | { |
| | 0 | 1049 | | return GetColumn(column, ref allRectColumns); |
| | 0 | 1050 | | } |
| | | 1051 | | |
| | | 1052 | | public RectInt[] GetRectIntColumn(int column) |
| | 0 | 1053 | | { |
| | 0 | 1054 | | return GetColumn(column, ref allRectIntColumns); |
| | 0 | 1055 | | } |
| | | 1056 | | |
| | | 1057 | | public Color[] GetColorColumn(int column) |
| | 0 | 1058 | | { |
| | 0 | 1059 | | return GetColumn(column, ref allColorColumns); |
| | 0 | 1060 | | } |
| | | 1061 | | |
| | | 1062 | | public LayerMask[] GetLayerMaskColumn(int column) |
| | 0 | 1063 | | { |
| | 0 | 1064 | | return GetColumn(column, ref allLayerMaskColumns); |
| | 0 | 1065 | | } |
| | | 1066 | | |
| | | 1067 | | public Bounds[] GetBoundsColumn(int column) |
| | 0 | 1068 | | { |
| | 0 | 1069 | | return GetColumn(column, ref allBoundsColumns); |
| | 0 | 1070 | | } |
| | | 1071 | | |
| | | 1072 | | public BoundsInt[] GetBoundsIntColumn(int column) |
| | 0 | 1073 | | { |
| | 0 | 1074 | | return GetColumn(column, ref allBoundsIntColumns); |
| | 0 | 1075 | | } |
| | | 1076 | | |
| | | 1077 | | public Hash128[] GetHash128Column(int column) |
| | 0 | 1078 | | { |
| | 0 | 1079 | | return GetColumn(column, ref allHash128Columns); |
| | 0 | 1080 | | } |
| | | 1081 | | |
| | | 1082 | | public Gradient[] GetGradientColumn(int column) |
| | 0 | 1083 | | { |
| | 0 | 1084 | | return GetColumn(column, ref allGradientColumns); |
| | 0 | 1085 | | } |
| | | 1086 | | |
| | | 1087 | | public AnimationCurve[] GetAnimationCurveColumn(int column) |
| | 0 | 1088 | | { |
| | 0 | 1089 | | return GetColumn(column, ref allAnimationCurveColumns); |
| | 0 | 1090 | | } |
| | | 1091 | | |
| | | 1092 | | public UnityEngine.Object[] GetObjectColumn(int column) |
| | 0 | 1093 | | { |
| | 0 | 1094 | | return GetColumn(column, ref allObjectRefColumns); |
| | 0 | 1095 | | } |
| | | 1096 | | |
| | | 1097 | | // Internal |
| | | 1098 | | |
| | | 1099 | | internal int AddColumnInternal<T>(string columnName, ref ArrayHolder<T>[] allColumnsOfType, Serializable.Seriali |
| | 0 | 1100 | | { |
| | 0 | 1101 | | int columnCount = allColumnsOfType?.Length ?? 0; |
| | 0 | 1102 | | Array.Resize(ref allColumnsOfType, columnCount + 1); |
| | 0 | 1103 | | allColumnsOfType[columnCount].TArray = new T[rowCount]; |
| | | 1104 | | |
| | 0 | 1105 | | string[] columnNamesForType = allColumnNames[(int)typeIndex].TArray; |
| | 0 | 1106 | | int columnNamesCount = columnNamesForType?.Length ?? 0; |
| | 0 | 1107 | | Array.Resize(ref columnNamesForType, columnNamesCount + 1); |
| | 0 | 1108 | | columnNamesForType[columnNamesCount] = columnName; |
| | 0 | 1109 | | allColumnNames[(int)typeIndex].TArray = columnNamesForType; |
| | | 1110 | | |
| | 0 | 1111 | | int columnIndex = columnEntriesFreeListHead; |
| | 0 | 1112 | | int columnIDToDenseIndexMapLength = columnIDToDenseIndexMap?.Length ?? 0; |
| | 0 | 1113 | | if (columnIndex >= columnIDToDenseIndexMapLength) |
| | 0 | 1114 | | { |
| | 0 | 1115 | | int newSize = columnIndex * 2; |
| | 0 | 1116 | | newSize = newSize == 0 ? 1 : newSize; |
| | 0 | 1117 | | Array.Resize(ref columnIDToDenseIndexMap, newSize); |
| | 0 | 1118 | | for (int i = 0; i < columnIndex; i++) |
| | 0 | 1119 | | { |
| | 0 | 1120 | | ref ColumnEntry entry = ref columnIDToDenseIndexMap[columnIndex + i]; |
| | 0 | 1121 | | entry.columnDenseIndex = columnIndex + i + 1; |
| | 0 | 1122 | | entry.ColumnType = Serializable.SerializableTypes.Invalid; |
| | 0 | 1123 | | } |
| | 0 | 1124 | | } |
| | | 1125 | | |
| | 0 | 1126 | | ref int[] denseIndexToIDMap = ref columnDenseIndexToIDMap[(int)typeIndex].TArray; |
| | 0 | 1127 | | int denseIndexToIDMapLength = denseIndexToIDMap?.Length ?? 0; |
| | 0 | 1128 | | Array.Resize(ref denseIndexToIDMap, denseIndexToIDMapLength + 1); |
| | 0 | 1129 | | denseIndexToIDMap[denseIndexToIDMapLength] = columnIndex; |
| | | 1130 | | |
| | 0 | 1131 | | ref ColumnEntry newEntry = ref columnIDToDenseIndexMap[columnIndex]; |
| | 0 | 1132 | | newEntry.columnDenseIndex = denseIndexToIDMapLength; |
| | 0 | 1133 | | newEntry.ColumnType = typeIndex; |
| | | 1134 | | |
| | 0 | 1135 | | insertAt = insertAt < 0 ? combinedColumnCount : insertAt; |
| | 0 | 1136 | | ref int[] columnOrdersOfType = ref allColumnOrders[(int)typeIndex].TArray; |
| | 0 | 1137 | | int columnOrdersOfTypeLength = columnOrdersOfType?.Length ?? 0; |
| | 0 | 1138 | | Array.Resize(ref columnOrdersOfType, columnOrdersOfTypeLength + 1); |
| | 0 | 1139 | | columnOrdersOfType[columnOrdersOfTypeLength] = insertAt; |
| | | 1140 | | |
| | 0 | 1141 | | for (int i = 0; i < Serializable.SerializableTypesCount; i++) |
| | 0 | 1142 | | { |
| | 0 | 1143 | | int[] columnOrdersOfTypeCurrent = allColumnOrders[i].TArray; |
| | 0 | 1144 | | int columnOrdersLength = columnOrdersOfTypeCurrent?.Length ?? 0; |
| | 0 | 1145 | | for (int j = 0; j < columnOrdersLength; j++) |
| | 0 | 1146 | | { |
| | 0 | 1147 | | int columnOrderCurrent = columnOrdersOfTypeCurrent[j]; |
| | | 1148 | | |
| | 0 | 1149 | | if (columnOrderCurrent > insertAt) |
| | 0 | 1150 | | { |
| | 0 | 1151 | | columnOrdersOfType[j] = columnOrderCurrent + 1; |
| | 0 | 1152 | | } |
| | 0 | 1153 | | } |
| | 0 | 1154 | | } |
| | | 1155 | | |
| | 0 | 1156 | | ++combinedColumnCount; |
| | 0 | 1157 | | dataVersion++; |
| | | 1158 | | |
| | 0 | 1159 | | return columnIndex; |
| | 0 | 1160 | | } |
| | | 1161 | | |
| | | 1162 | | internal void RemoveColumnInternal<T>(ref ArrayHolder<T>[] allColumnsOfType, Serializable.SerializableTypes type |
| | 0 | 1163 | | { |
| | 0 | 1164 | | int columnLocation = columnIDToDenseIndexMap[column].columnDenseIndex; |
| | | 1165 | | |
| | 0 | 1166 | | int lastIndex = allColumnsOfType.Length - 1; |
| | 0 | 1167 | | allColumnsOfType[columnLocation] = allColumnsOfType[lastIndex]; |
| | | 1168 | | // T[][] newColumnArray = new T[lastIndex][]; |
| | 0 | 1169 | | ArrayHolder<T>[] newColumnArray = new ArrayHolder<T>[lastIndex]; |
| | 0 | 1170 | | Array.Copy(allColumnsOfType, 0, newColumnArray, 0, lastIndex); |
| | 0 | 1171 | | allColumnsOfType = newColumnArray; |
| | | 1172 | | |
| | 0 | 1173 | | string[] columnNamesOfType = allColumnNames[(int)typeIndex].TArray; |
| | 0 | 1174 | | columnNamesOfType[columnLocation] = columnNamesOfType[lastIndex]; |
| | 0 | 1175 | | string[] newColumnNamesOfType = new string[lastIndex]; |
| | 0 | 1176 | | Array.Copy(columnNamesOfType, 0, newColumnNamesOfType, 0, lastIndex); |
| | 0 | 1177 | | allColumnNames[(int)typeIndex].TArray = newColumnNamesOfType; |
| | | 1178 | | |
| | 0 | 1179 | | int[] columnOrdersOfType = allColumnOrders[(int)typeIndex].TArray; |
| | 0 | 1180 | | int columnOrder = columnOrdersOfType[columnLocation]; |
| | 0 | 1181 | | columnOrdersOfType[columnLocation] = columnOrdersOfType[lastIndex]; |
| | 0 | 1182 | | int[] newColumnOrdersOfType = new int[lastIndex]; |
| | 0 | 1183 | | Array.Copy(columnOrdersOfType, 0, newColumnOrdersOfType, 0, lastIndex); |
| | 0 | 1184 | | allColumnOrders[(int)typeIndex].TArray = newColumnOrdersOfType; |
| | | 1185 | | |
| | 0 | 1186 | | int[] denseIndicesOfType = columnDenseIndexToIDMap[(int)typeIndex].TArray; |
| | 0 | 1187 | | int sparseIndexAt = denseIndicesOfType[columnLocation]; |
| | 0 | 1188 | | int sparseIndexToSwap = columnOrdersOfType[lastIndex]; |
| | 0 | 1189 | | ref ColumnEntry sparseIndexToFree = ref columnIDToDenseIndexMap[sparseIndexAt]; |
| | 0 | 1190 | | sparseIndexToFree.ColumnType = Serializable.SerializableTypes.Invalid; |
| | 0 | 1191 | | sparseIndexToFree.columnDenseIndex = columnEntriesFreeListHead; |
| | 0 | 1192 | | columnEntriesFreeListHead = sparseIndexAt; |
| | 0 | 1193 | | columnIDToDenseIndexMap[sparseIndexToSwap].columnDenseIndex = columnLocation; |
| | 0 | 1194 | | denseIndicesOfType[columnLocation] = sparseIndexToSwap; |
| | 0 | 1195 | | int[] newDenseIndicesOfType = new int[lastIndex]; |
| | 0 | 1196 | | Array.Copy(denseIndicesOfType, 0, newDenseIndicesOfType, 0, lastIndex); |
| | 0 | 1197 | | columnDenseIndexToIDMap[(int)typeIndex].TArray = newDenseIndicesOfType; |
| | | 1198 | | |
| | 0 | 1199 | | for (int i = 0; i < Serializable.SerializableTypesCount; i++) |
| | 0 | 1200 | | { |
| | 0 | 1201 | | int[] columnOrdersOfTypeCurrent = allColumnOrders[i].TArray; |
| | | 1202 | | |
| | 0 | 1203 | | int columnOrdersLength = columnOrdersOfTypeCurrent.Length; |
| | 0 | 1204 | | for (int j = 0; j < columnOrdersLength; j++) |
| | 0 | 1205 | | { |
| | 0 | 1206 | | int columnOrderCurrent = columnOrdersOfTypeCurrent[j]; |
| | | 1207 | | |
| | 0 | 1208 | | if (columnOrderCurrent > columnOrder) |
| | 0 | 1209 | | { |
| | 0 | 1210 | | columnOrdersOfType[j] = columnOrderCurrent - 1; |
| | 0 | 1211 | | } |
| | 0 | 1212 | | } |
| | 0 | 1213 | | } |
| | | 1214 | | |
| | 0 | 1215 | | --combinedColumnCount; |
| | 0 | 1216 | | dataVersion++; |
| | 0 | 1217 | | } |
| | | 1218 | | |
| | | 1219 | | internal void InsertRowsOfTypeInternal<T>(ref ArrayHolder<T>[] allColumnsOfType, int insertAt, int numberOfNewRo |
| | 0 | 1220 | | { |
| | 0 | 1221 | | int columnCount = allColumnsOfType?.Length ?? 0; |
| | 0 | 1222 | | for (int i = 0; i < columnCount; i++) |
| | 0 | 1223 | | { |
| | 0 | 1224 | | ref T[] column = ref allColumnsOfType[i].TArray; |
| | 0 | 1225 | | int newRowCount = rowCount + numberOfNewRows; |
| | 0 | 1226 | | Array.Resize(ref column, newRowCount); |
| | 0 | 1227 | | for (int j = newRowCount - 1; j > insertAt + numberOfNewRows - 1; j--) |
| | 0 | 1228 | | { |
| | 0 | 1229 | | column[j] = column[j - numberOfNewRows]; |
| | 0 | 1230 | | } |
| | | 1231 | | |
| | 0 | 1232 | | for (int j = 0; j < numberOfNewRows; j++) |
| | 0 | 1233 | | { |
| | 0 | 1234 | | column[insertAt + j] = default; |
| | 0 | 1235 | | } |
| | 0 | 1236 | | } |
| | 0 | 1237 | | } |
| | | 1238 | | |
| | | 1239 | | internal void DeleteRowsOfTypeInternal<T>(ref ArrayHolder<T>[] allColumnsOfType, int removeAt, int numberOfRowsT |
| | 0 | 1240 | | { |
| | 0 | 1241 | | int columnCount = allColumnsOfType?.Length ?? 0; |
| | | 1242 | | |
| | 0 | 1243 | | for (int i = 0; i < columnCount; i++) |
| | 0 | 1244 | | { |
| | 0 | 1245 | | ref T[] column = ref allColumnsOfType[i].TArray; |
| | 0 | 1246 | | int newRowCount = rowCount - numberOfRowsToDelete; |
| | | 1247 | | |
| | 0 | 1248 | | for (int j = removeAt; j < rowCount - numberOfRowsToDelete; j++) |
| | 0 | 1249 | | { |
| | 0 | 1250 | | column[j] = column[j + numberOfRowsToDelete]; |
| | 0 | 1251 | | } |
| | | 1252 | | |
| | 0 | 1253 | | Array.Resize(ref column, newRowCount); |
| | 0 | 1254 | | } |
| | 0 | 1255 | | } |
| | | 1256 | | |
| | | 1257 | | internal ref T GetCellRef<T>(int rowID, int columnID, ref ArrayHolder<T>[] allColumnsOfType) |
| | 0 | 1258 | | { |
| | 0 | 1259 | | int column = columnIDToDenseIndexMap[columnID].columnDenseIndex; |
| | 0 | 1260 | | return ref allColumnsOfType[column][rowID]; |
| | 0 | 1261 | | } |
| | | 1262 | | |
| | | 1263 | | internal T GetCell<T>(int rowID, int columnID, ref ArrayHolder<T>[] allColumnsOfType) |
| | 0 | 1264 | | { |
| | 0 | 1265 | | int column = columnIDToDenseIndexMap[columnID].columnDenseIndex; |
| | 0 | 1266 | | return allColumnsOfType[column][rowID]; |
| | 0 | 1267 | | } |
| | | 1268 | | |
| | | 1269 | | internal ulong SetCell<T>(int rowID, int columnID, ref ArrayHolder<T>[] allColumnsOfType, T value) |
| | 0 | 1270 | | { |
| | 0 | 1271 | | int column = columnIDToDenseIndexMap[columnID].columnDenseIndex; |
| | 0 | 1272 | | allColumnsOfType[column][rowID] = value; |
| | 0 | 1273 | | dataVersion++; |
| | 0 | 1274 | | return dataVersion; |
| | 0 | 1275 | | } |
| | | 1276 | | |
| | | 1277 | | internal T[] GetColumn<T>(int columnID, ref ArrayHolder<T>[] allColumnsOfType) |
| | 0 | 1278 | | { |
| | 0 | 1279 | | int column = columnIDToDenseIndexMap[columnID].columnDenseIndex; |
| | 0 | 1280 | | return allColumnsOfType[column].TArray; |
| | 0 | 1281 | | } |
| | | 1282 | | } |
| | | 1283 | | } |